import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.chagee.store.operation.api.response.vo.AiResultVO;
import com.chagee.store.operation.server.DubboProviderApplication;
import com.chagee.store.operation.server.service.biz.SupplierWorkOrderBizService;
import com.chagee.store.operation.server.service.biz.WorkOrderBizService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author : hk
 * @Date : 2024/9/30
 */

@Slf4j
@SpringBootTest(classes = DubboProviderApplication.class, properties = "spring.config.location=classpath:application-local.yml")
public class SupplierWorkOrderController {

	public static void main(String[] args) {
		String aaa = "[{\"code\":200,\"fileName\":\"miniapp_17276800287390.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800287390.png\",\"itemCount\":0,\"items\":[{\"id\":1,\"label\":\"outlet_cling_film\",\"location\":{\"height\":564.0,\"left\":51.0,\"top\":78.0,\"width\":699.0},\"score\":97}],\"size\":1331574,\"type\":\"TEA_OUTLET\"},{\"code\":200,\"fileName\":\"miniapp_17276800343830.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800343830.png\",\"itemCount\":0,\"size\":475432,\"type\":\"SILO\"},{\"code\":200,\"fileName\":\"miniapp_17276800397000.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800397000.png\",\"itemCount\":0,\"size\":427371,\"type\":\"OUTLET\"},{\"code\":200,\"fileName\":\"miniapp_17276800438540.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800438540.png\",\"itemCount\":0,\"size\":745716,\"type\":\"PERISTALTIC_PUMP\"},{\"fileName\":\"miniapp_17276800515540.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800515540.png\",\"size\":673855,\"type\":\"DOOR_FRAME_SLIDING_RAIL\"},{\"fileName\":\"miniapp_17276800709310.jpg\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800709310.jpg\",\"size\":287574,\"type\":\"TEA_DRINKING_MACHINE_SURFACE\"},{\"fileName\":\"miniapp_17276800774610.jpg\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800774610.jpg\",\"size\":277707,\"type\":\"\"},{\"fileName\":\"miniapp_17276800774951.jpg\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800774951.jpg\",\"size\":137969,\"type\":\"\"},{\"fileName\":\"miniapp_17276800774962.jpg\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800774962.jpg\",\"size\":406501,\"type\":\"\"}]";
		List<AiResultVO> aiResultVOS = JSON.parseObject(aaa, new TypeReference<List<AiResultVO>>() {});
		List<AiResultVO> aiResultVOS1 = JSONArray.parseArray(aaa, AiResultVO.class);
		System.out.println(JSON.toJSONString(aiResultVOS1));
	}

	@Resource
	private SupplierWorkOrderBizService supplierWorkOrderBizService;

	@Resource
	private WorkOrderBizService workOrderBizService;

	@Test
	public void testTaxReportDetail() {
		//receiverID=null, storeCode=[], allStoreStatus=0, storeName=null, startCreateTime=, endCreateTime=, documentStatus=100, userType=2, supplierId=null, companyId=, isQualified=null
		/*PaginationRequest<SupplierWorkOrderQueryParam> queryParam = new PaginationRequest<>();
		queryParam.setPageSize(10);
		queryParam.setPageNum(1);
		SupplierWorkOrderQueryParam param = new  SupplierWorkOrderQueryParam();
		param.setAllStoreStatus("0");
		param.setDocumentStatus("100");
		param.setUserType(2);
		param.setReceiverID(1769545882561994753L);
		param.setUserType(2);
		param.setSupplierId(123L);
		queryParam.setQueryParameter(param);
		PaginationData<SupplierWorkOrderVO> queryList = supplierWorkOrderBizService.queryList(queryParam);
		System.out.println(JSONUtil.toJsonStr(queryList));*/
		//List<AiResultVO> aiResultVOS = JSONArray.parseArray(aaa, AiResultVO.class);

		String aaa = "[{\"code\":200,\"fileName\":\"miniapp_17276800287390.png\",\"filePath\":\"https://chagee20.oss-cn-shanghai.aliyuncs.com/chagee20/images/20240930/miniapp_17276800287390.png\",\"itemCount\":0,\"items\":[{\"id\":1,\"label\":\"outlet_cling_film\",\"location\":{\"height\":564.0,\"left\":51.0,\"top\":78.0,\"width\":699.0},\"score\":97}],\"size\":1331574,\"type\":\"TEA_OUTLET\"}]";

		JSONArray objects = JSON.parseArray(aaa);
//		List<AiResultVO> aiResultVOS = JSON.parseObject(objects.toJSONString(), new TypeReference<List<AiResultVO>>() {});
		List<JSONObject> aiResultVOS = JSONObject.parseArray(objects.toJSONString(), JSONObject.class);
		List<AiResultVO> results = new ArrayList<>();
		System.out.println(JSON.toJSON(results));
	}

	@Test
	public void distinctSupplier(){
		List<String> list = workOrderBizService.distinctSupplier();
		System.out.println(JSON.toJSONString(list));
	}

}
